package com.aspose.cells.a.d;

import com.aspose.cells.Encoding;
import java.util.ArrayList;

public class zfi extends zfw {
   public int a;
   public int b;
   public short c;
   public short d;
   public int e;
   public int f;
   public int g;
   public int h;
   public int i;
   public int j;
   public int[] k;
   public ArrayList l;

   public zfi(zu var1) throws Exception {
      this.a = var1.b();
      this.b = var1.b();
      this.c = var1.d();
      this.d = var1.d();
      this.e = var1.b();
      this.f = var1.b();
      this.g = var1.b();
      this.h = var1.b();
      this.i = var1.b();
      switch(this.a) {
      case 131072:
         this.j = var1.e() & '\uffff';
         this.k = new int[this.j];
         int var2 = 0;

         int var3;
         int var4;
         for(var3 = 0; var3 < this.k.length; ++var3) {
            var4 = var1.e();
            this.k[var3] = var4 & '\uffff';
            if ((var4 & '\uffff') <= 32767) {
               var2 = Math.max(var4 & '\uffff', var2);
            }
         }

         var3 = var2 - 258 + 1;
         var3 = var3 < 0 ? 0 : var3;
         this.l = new ArrayList(var3);

         for(var4 = 0; var4 < var3; ++var4) {
            com.aspose.cells.b.a.a.ze.a(this.l, (Object)a(var1));
         }
      case 65536:
      case 196608:
         return;
      default:
         throw new IllegalStateException("Unexpected PostScript table version.");
      }
   }

   public void a(zv var1) throws Exception {
      var1.a(this.a);
      var1.a(this.b);
      var1.b(this.c);
      var1.b(this.d);
      var1.a(this.e);
      var1.a(this.f);
      var1.a(this.g);
      var1.a(this.h);
      var1.a(this.i);
      switch(this.a) {
      case 131072:
         var1.b(this.j);
         int[] var2 = this.k;
         int var3 = var2.length;

         for(int var4 = 0; var4 < var3; ++var4) {
            int var5 = var2[var4];
            var1.b(var5);
         }

         for(int var6 = 0; var6 < this.l.size(); ++var6) {
            a((String)this.l.get(var6), var1);
         }
      case 65536:
      case 196608:
         return;
      default:
         throw new IllegalStateException("Unexpected PostScript table version.");
      }
   }

   public void a(zfj var1) {
      this.f = 0;
      this.g = 0;
      this.h = 0;
      this.i = 0;
      switch(this.a) {
      case 131072:
         this.b(var1);
      case 65536:
      case 196608:
         return;
      default:
         throw new IllegalStateException("Unexpected PostScript table version.");
      }
   }

   private void b(zfj var1) {
      int[] var2 = new int[var1.a()];
      ArrayList var3 = new ArrayList();

      for(int var4 = 0; var4 < var1.a(); ++var4) {
         int var5 = var1.d(var4);
         int var6 = (Integer)var1.c(var4);
         int var7 = this.k[var5];
         if (var7 >= 258 && var7 <= 32767) {
            String var8 = (String)this.l.get(var7 - 258);
            int var9 = com.aspose.cells.b.a.a.ze.a(var3, (Object)var8);
            var2[var6] = var9 + 258 & '\uffff';
         } else {
            var2[var6] = var7 & '\uffff';
         }
      }

      this.j = var1.a() & '\uffff';
      this.k = var2;
      this.l = var3;
   }

   private static String a(zu var0) throws Exception {
      int var1 = var0.f() & 255;
      byte[] var2 = var0.a(var1);
      Encoding var3 = Encoding.getASCII();
      return var3.a(var2);
   }

   private static void a(String var0, zv var1) throws Exception {
      if (var0.length() > 255) {
         throw new IllegalStateException("The PostScript glyph name is too long.");
      } else {
         Encoding var2 = Encoding.getASCII();
         byte[] var3 = var2.a(var0);
         var1.a((byte)var3.length);
         var1.a(var3, 0, var3.length);
      }
   }
}
